package com.hxmall.appclient;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Author Eirunye
 * Created by on 2018/9/11.
 * Describe
 */

@Configuration
@EnableSwagger2
@ComponentScan(basePackages = {"com.hxmall.appclient.controller.product"})
public class Swagger2Config {

    /**
     * 创建Swagger2API基本信息
     * @return 返回文档
     */
    @Bean
    public Docket createRestApi() {

        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiInfo())
                .select()
//                .apis(RequestHandlerSelectors.basePackage("com.hxmall.appclient.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * API 显示在Swagger UI上
     * @return ApiInfo
     */
    private ApiInfo getApiInfo() {

        return new ApiInfoBuilder()
                .title("韩讯后台API")    //标题
                .description("韩讯后台API提供接口") //描述
                .version("1.0")  //版本号
                .build();

    }
}
